<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>询价单详情</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="format-detection" content="telephone=no">
	<link rel="stylesheet" type="text/css" href="../../common/bootstrap/css/bootstrap.css" media="all">
	<link rel="stylesheet" type="text/css" href="../../common/layui/css/layui.css" media="all">
	<link rel="stylesheet" type="text/css" href="../../common/global.css" media="all">
	<link rel="stylesheet" type="text/css" href="../../css/customer_list.css" media="all">
	<link rel="stylesheet" type="text/css" href="../../common/module/formSelects/formSelects-v4.css" media="all">
</head>
<style>
	.layui-form-item .layui-input-inline {
		font-size: 14px;
		/*width: 210px;*/
		width: 250px;
		margin-right: 10px;
	}
	.layui-input-block {
		margin-left: 95px;
	}
	.main_content_wrap{
		margin-top: 0px;
	}

	.layui-form-item .file-info {
		float: left;
		width: 400px;
		margin-right: 10px;
	}
	.layui-form-item .file-icon {
		float: left;
		width: 95px;
		margin-left: 10px;
	}
	.detail_wrap{
		padding: 0 50px;
	}
	.max_w{
		max-width: 950px;
	}
	.order_massage{
		width: 100%;
		margin-left: 30px;
		font-size: 14px;
	}
	.order_massage li{
		padding: 20px 10px;
	}
	.order_massage li:first-child{
		padding-top: 0px;
	}
	.order_massage li:last-child{
		border-bottom: none;
	}
	.order_massage_title{
		float: left;
		width: 22%;
	}
	.order_address_title{
		float: left;
		width: 50%;
	}
	.state_icon{
		width: 100px;
		height: auto;
		position: absolute; /* 使用绝对定位 */
		top: 15%;
		right: 10%;
		object-fit: cover;  /* 确保图片适应容器 */
	}
</style>
<body>
<!-- 添加车辆和司机 -->
<div class="layui-fluid content_box">
	<div class="main_content_wrap">
		<form class="layui-form add_form" lay-filter="addForm" id="addForm" action="">
			<p class="add_title">基础信息</p>
			<div class="layui-card-body" id="orderView">
			</div>
			<input hidden name="id" />
			<p class="add_title">零件清单</p>
			<div class="detail_wrap">
				<table class="layui-table max_w" id="infoTable" lay-filter="infoTable"></table>
			</div>
			<div class="layui-form-item text-center">
				<div class="layui-input-block" id="again" style="max-width: none;display: none">
					<button class="layui-btn btn-red site-demo-active" style="margin-right: 10%" id="againInquiry">重新报价</button>
				</div>
			</div>
		</form>
	</div>
</div>
<script id="orderDetail" type="text/html">
	<ul class='order_massage'>
		<li>
			<span class="order_massage_title">询价单号：{{d.bus_inquiry_no}}</span>
			<span class="order_massage_title">询价日期：{{d.add_datetime}}</span>
			<span class="order_massage_title">到期时间：{{d.deadline_datetime?d.deadline_datetime:''}}</span>
			<span class="">
				{{# if(d.inquiry_state == 3){ }}
				<img src="../../img/closed.png" class="state_icon">
				{{# }else if(d.state == 4){ }}
				<img src="../../img/abandon.png" class="state_icon">
				{{# }else if(d.state==3){ }}
				<img src="../../img/returned.png" class="state_icon">
				{{# }else if(d.state==7){ }}
				<img src="../../img/unchoose.png" class="state_icon">
				{{# }else if(d.state==2 || d.state > 4){ }}
				<img src="../../img/quoted.png" class="state_icon">
				{{# }else{ }}
				<img src="../../img/pending_quotation.png" class="state_icon">
				{{# } }}
			</span>
			<span class="order_massage_title">业务员：{{d.add_user_name?d.add_user_name:''}}</span>
		</li>
		<li>
			<span class="order_massage_title">车牌号：{{d.vehicle_license_num?d.vehicle_license_num:''}}</span>
			<span class="order_massage_title">车架号：{{d.vehicle_frame_no}}</span>
			<span class="order_massage_title">品牌名称：{{d.brand_name?d.brand_name:''}}</span>
			<span class="order_massage_title">车型名称：{{d.car_model?d.car_model:''}}</span>
		</li>
		<li>
			<span class="order_massage_title" style="font-weight: bold">备注：{{d.common?d.common:''}}</span>
		</li>
	</ul>
</script>
<script type="text/html" id="serviceTpl">
	{{# if(d.id > 0){ }}
	{{# if(d.qulity_service_state == 1){ }}
		{{d.qulity_service_price>0?d.qulity_service_price:''}}
	{{# }else{ }}
	<div contenteditable="false"  style="height: 100%; width: 100%; outline: none; cursor:'not-allowed'; background-color: #f3f2f2" ></div>
	{{# } }}
	{{# }else{ }}
	{{d.qulity_service_price}}
	{{# } }}
</script>

<script type="text/html" id="orgTpl">
	{{# if(d.id > 0){ }}
	{{# if(d.qulity_org_state == 1){ }}
	{{d.qulity_org_price>0?d.qulity_org_price:''}}
	{{# }else{ }}
	<div contenteditable="false"  style="height: 100%; width: 100%; outline: none; cursor:'not-allowed'; background-color: #f3f2f2" ></div>
	{{# } }}
	{{# }else{ }}
	{{d.qulity_org_price}}
	{{# } }}
</script>

<script type="text/html" id="matchingTpl">
	{{# if(d.id > 0){ }}
	{{# if(d.qulity_matching_state == 1){ }}
		{{d.qulity_matching_price>0?d.qulity_matching_price:''}}
	{{# }else{ }}
	<div contenteditable="false"  style="height: 100%; width: 100%; outline: none; cursor:'not-allowed'; background-color: #f3f2f2" ></div>
	{{# } }}
	{{# }else{ }}
	{{d.qulity_matching_price}}
	{{# } }}
</script>

<script type="text/html" id="completeTpl">
	{{# if(d.id > 0){ }}
	{{# if(d.qulity_complete_state == 1){ }}
	{{d.qulity_complete_price>0?d.qulity_complete_price:''}}
	{{# }else{ }}
	<div contenteditable="false"  style="height: 100%; width: 100%; outline: none; cursor:'not-allowed'; background-color: #f3f2f2" ></div>
	{{# } }}
	{{# }else{ }}
	{{d.qulity_complete_price}}
	{{# } }}
</script>

<script type="text/html" id="suitableTpl">
	{{# if(d.id > 0){ }}
	{{# if(d.qulity_suitable_state == 1){ }}
	{{d.qulity_suitable_price>0?d.qulity_suitable_price:''}}
	{{# }else{ }}
	<div contenteditable="false"  style="height: 100%; width: 100%; outline: none; cursor:'not-allowed'; background-color: #f3f2f2" ></div>
	{{# } }}
	{{# }else{ }}
	{{d.qulity_suitable_price}}
	{{# } }}
</script>

<!--放弃报价-->
<script type="text/html" id="cancleForm">
	<form lay-filter="cancleForm" class="layui-form model-form">
		<input name="id" hidden/>
		<div class="layui-form-item">
			<label class="layui-form-label">备注:</label>
			<div class="layui-input-inline">
				<textarea name="common" placeholder="请输入理由" class="layui-textarea" lay-verify="required" required></textarea>
			</div>
		</div>
		<div class="layui-form-item text-center">
			<button class="layui-btn" type="button" ew-event="closeDialog">取消</button>
			<button type="button" lay-filter="cancleFormSubmit" lay-submit class="layui-btn site-demo-active">确认</button>
		</div>
	</form>
</script>

<script type="text/html" id="priceTpl">
	{{# if(d.qulity_matching_state == 1){ }}
	<div contenteditable="true"  style="outline: none; cursor: 'text';" >
		{{ d.qulity_matching_price?d.qulity_matching_price:'' }}
	</div>
	{{# }else{ }}
	<div contenteditable="false"  style="height: 100%; width: 100%; outline: none; cursor:'not-allowed'; background-color: #cccccc" ></div>
	{{# } }}
</script>
<script type="text/javascript" src="../../js/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="../../js/jquery.cookie.js"></script>
<script type="text/javascript" src="../../common/layui/layui2.js"></script>
<script type="text/javascript" src="../../js/common.js"></script>
<script type="text/javascript" src="../../js/main.js"></script>
<script type="text/javascript" src="../../jsplug/xm-select.js"></script>
<script>
	var id = GetQueryString('id');
	$(function () {
		layui.use(['jquery', 'form', 'upload', 'laydate', 'admin', 'table', 'formSelects', 'laytpl'], function () {
			var $ = layui.jquery;
			var form = layui.form;
			var table = layui.table;
			var upload = layui.upload;
			var laydate = layui.laydate;
			var formSelects = layui.formSelects;
			var admin = layui.admin;
			var laytpl = layui.laytpl;

			var res_data = {};

			laydate.render({
				elem: '#deadline_datetime'
				, trigger: 'click',
				type: 'datetime', // 设置类型为 datetime
				format: 'yyyy-MM-dd HH', // 设置显示格式
			});
			form.render();

			var detailList = [];

			var DISABLED = 'layui-btn-disabled';

			getInfo();

			function getInfo() {
				send_req('Inquiry/getInfo', {id: id}, function (data) {
					res_data = data;
					if (res_data.inquiry_state < 3 && res_data.state < 6) {
						$('#again').show();
					}
					var orderDetail = document.getElementById('orderDetail');
					var getTpl = orderDetail.innerHTML;
					var view = document.getElementById('orderView');
					laytpl(getTpl).render(data, function (html) {
						view.innerHTML = html;
					});
					detailList = data.detail_info;
					tableIns.reload({
						data: detailList // 将新数据与现有缓存合并
					});
				});
			}

			form.render();

			var tableIns = table.render({
				elem: '#infoTable',
				id: 'infoTable',
				limit: 100,
				data: detailList,
				page: false,
				cols: [[
					{type: 'numbers', title: '序号'},
					{field: 'eq_name', title: '零件名称',width:200},
					{field: 'oe_no', title: '0E码',width:200},
					{field: 'num', title: '数量',width:70},
					{field: 'qulity_service_price', title: '服务站价', templet: '#serviceTpl',width:100},
					{field: 'qulity_org_price', title: '原厂原包价', templet: '#orgTpl',width:100},
					{field: 'qulity_matching_price', title: '配套件价', templet: '#matchingTpl'},
					{field: 'qulity_complete_price', title: '品牌件价', templet: '#completeTpl'},
					{field: 'qulity_suitable_price', title: '适用件', templet: '#suitableTpl'},
					{field: 'common', title: '备注'},
				]],
				done: function (res, curr, count) {
					form.render();
				}
			});

			$('#againInquiry').click(function () {
				window.parent.go_to_page_general('./html/inquiry/quote.html', 'id=' + id);
				return false;
			});
		});
	});
</script>
</body>
</html>